import { Column, Entity, ManyToMany, PrimaryGeneratedColumn } from 'typeorm'
import { ApiProperty } from '@nestjs/swagger'

import { BaseModels, PostEntity } from './index'

/**
 * @package 分类
 * @author liu
 */
@Entity({ name: 'category' })
export class CategoryEntity extends BaseModels {
  @PrimaryGeneratedColumn()
  id: number

  @Column({ default: '', comment: '分类名称' })
  name: string

  @Column({ type: 'int', default: 0, name: 'is_top', comment: '是否热门' })
  isTop: number

  @ManyToMany(type => PostEntity, post => post.category)
  post: PostEntity[]
}
